package com.rc.saas.tenant.service.enterprise;

import com.rc.saas.tenant.mapper.enterprise.RcEnterpriseGainRecordMapper;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseGainRecord;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseGainRecordExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RcEnterpriseGainRecordServiceImpl implements RcEnterpriseGainRecordService{

    @Autowired
    private RcEnterpriseGainRecordMapper enterpriseGainRecordMapper;

    @Override
    public RcEnterpriseGainRecordMapper getMapper() {
        return enterpriseGainRecordMapper;
    }

    @Override
    public RcEnterpriseGainRecord selectGainRecordByGain(Long enterpriseId, Long gainId) {
        return enterpriseGainRecordMapper.selectGainRecordByGain(enterpriseId, gainId);
    }

    @Override
    public void insertReturnId(RcEnterpriseGainRecord enterpriseGainRecord) {
        enterpriseGainRecordMapper.insertReturnId(enterpriseGainRecord);
    }

    @Override
    public RcEnterpriseGainRecord selectGainRecordByEnterprise(Long enterpriseId) {
        return enterpriseGainRecordMapper.selectGainRecordByEnterprise(enterpriseId);
    }

    @Override
    public void deleteGainRecordByEnterpriseId(Long enterpriseId) {
        RcEnterpriseGainRecordExample example = new RcEnterpriseGainRecordExample();
        example.createCriteria().andEnterpriseIdEqualTo(enterpriseId);
        List<RcEnterpriseGainRecord> list = enterpriseGainRecordMapper.selectByExample(example);
        for (RcEnterpriseGainRecord record : list) {
            enterpriseGainRecordMapper.deleteByPrimaryKey(record.getEnterpriseGainRecordId());
        }
    }
}
